﻿using System.Data.Entity;
using System.Linq;
using System.Web.Mvc;
using ZBJF.Warranty.BLL;
using ZBJF.Warranty.Common.Common;
using ZBJF.Warranty.Common.Enums.InsuranceProducts;
using ZBJF.Warranty.Model;
using ZBJF.Warranty.Model.ViewModel.BaseQueryModel;
using ZBJF.Warranty.Model.ViewModel.Log;

namespace ZBJF.Warranty.AdminSite.Controllers
{
    public class PubModelDialogController : Controller
    {
        public ActionResult InsuranceOrderCheckLogList()
        {
            return View();
        }
        public ActionResult InfoCollectItemSelector()
        {
            return View();
        }
        public ActionResult CollectTypeCollectItemMappingsSelector()
        {
            return View();
        }
        public ActionResult SellersOrganizationSelector()
        {
            return View();
        }
        public ActionResult InsuranceCompanySelector()
        {
            return View();
        }
        public ActionResult PageMenuSelector()
        {
            return View();
        }
        [HttpPost]
        public JsonResult GetSellerOrganizationTree()
        {
            var list = ServiceFactory.SellersOrganizationServiceInstance.GetSellersOrganizationAll()
                     .AsNoTracking()
                     .Select(o => new
                     {
                         ID = o.ID,
                         PID = o.ParentOrganizationId,
                         name = o.OrganizationName
                     }).ToList();
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        [HttpPost]
        public JsonResult GetInsuranceCompanyTree()
        {
            var list = ServiceFactory.InsuranceCompanyServiceInstance.GetInsuranceCompanyAll(false)
                     .AsNoTracking()
                     .Select(o => new
                     {
                         ID = o.ID,
                         PID = o.ParentID,
                         name = o.CompanyName
                     }).ToList();
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        [HttpPost]
        public JsonResult GetPageMunuTree()
        {
            var list = ServiceFactory.PageMenuServiceInstance.LoadAllPageMenus().OrderBy(o => o.BelongApplicationType)
                     .AsNoTracking()
                     .Select(o => new
                     {
                         ID = o.ID,
                         PID = o.ParentID,
                         name = o.PageName,
                         o.BelongApplicationType
                     }).ToList();
            return Json(list, JsonRequestBehavior.AllowGet);
        }
    }
}
